﻿#

param
(
	[ValidateSet("n","*","1","2","3","4","5","6","7","8","9","10","11","12")]
	[Alias("months")][array]$月 = 'n',

	[ValidateSet("n","*","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31")]
	[Alias("days")][array]$日 = 'n',

	#月日和【周】互斥。
	[ValidateSet("n","*","1","2","3","4","5","6","7")]
	[Alias("weeks")][array]$周 = 'n',

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_00_hour")][array]$分钟_in_00小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_01_hour")][array]$分钟_in_01小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_02_hour")][array]$分钟_in_02小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_03_hour")][array]$分钟_in_03小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_04_hour")][array]$分钟_in_04小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_05_hour")][array]$分钟_in_05小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_06_hour")][array]$分钟_in_06小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_07_hour")][array]$分钟_in_07小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_08_hour")][array]$分钟_in_08小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_09_hour")][array]$分钟_in_09小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_10_hour")][array]$分钟_in_10小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_11_hour")][array]$分钟_in_11小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_12_hour")][array]$分钟_in_12小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_13_hour")][array]$分钟_in_13小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_14_hour")][array]$分钟_in_14小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_15_hour")][array]$分钟_in_15小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_16_hour")][array]$分钟_in_16小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_17_hour")][array]$分钟_in_17小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_18_hour")][array]$分钟_in_18小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_19_hour")][array]$分钟_in_19小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_20_hour")][array]$分钟_in_20小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_21_hour")][array]$分钟_in_21小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_22_hour")][array]$分钟_in_22小时,

	[ValidateSet('*',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59)]
	[Alias("minutes_in_23_hour")][array]$分钟_in_23小时,

	#不建议用卡死你3000执行，循环少于10秒的任务计划。
	[ValidateSet('*',5,15,25,35,45,55)]
	[Alias("seconds")][array]$秒 = 5,

	#0=停用。1=启用。2=一次性触发器。
	[ValidateSet(0,1,2)]
	[Alias("enable")][int]$启用状态 = 1,

	[Alias("remark")][String]$备注
)

if ( ($月 -eq 'n') -and ($日 -eq 'n') -and ($周 -eq 'n') )
{
	Write-Error "错误：月日周都【不】存在。若输入日月，则周应输入n。错误码11"
	exit 11
}

if ( ($月 -ne 'n') -and ($日 -ne 'n') -and ($周 -ne 'n') )
{
	Write-Error "错误：月日周都存在。若输入周，则日月应输入n。错误码12"
	exit 12
}

if ( ($月 -eq 'n') -and ($日 -ne 'n') )
{
	Write-Error "错误：没有月份。错误码13"
	exit 13
}

if ( ($月 -ne 'n') -and ($日 -eq 'n') )
{
	Write-Error "错误：有月份，没有日。错误码14"
	exit 14
}

if ($月 -eq '*')
{
	Remove-Variable 月
	$private:月 = 1,2,3,4,5,6,7,8,9,10,11,12
}

if ($日 -eq '*')
{
	Remove-Variable 日
	$private:日 = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
}

if ($周 -eq '*')
{
	Remove-Variable 周
	$private:周 = 1,2,3,4,5,6,7
}


if ('*' -in $秒)
{
	Remove-Variable 秒
	$private:秒2 = 5,15,25,35,45,55
}
else
{
	$private:秒999 = 5,15,25,35,45,55
	foreach ($private:temp998 in $秒)
	{
		if ($private:temp998 -In $private:秒999)
		{
			$秒997 += $private:temp998
		}
		else
		{
			Write-Error "错误：秒的值，输入错误。错误码15"
			exit 15
		}
	}
	$private:秒2 = ($private:秒997 | Sort-Object -Unique) -join ','
}


if ('*' -in $分钟_in_00小时)
{
	Remove-Variable 分钟_in_00小时
	$private:分钟_in_00小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_01小时)
{
	Remove-Variable 分钟_in_01小时
	$private:分钟_in_01小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_02小时)
{
	Remove-Variable 分钟_in_02小时
	$private:分钟_in_02小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_03小时)
{
	Remove-Variable 分钟_in_03小时
	$private:分钟_in_03小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_04小时)
{
	Remove-Variable 分钟_in_04小时
	$private:分钟_in_04小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_05小时)
{
	Remove-Variable 分钟_in_05小时
	$private:分钟_in_05小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_06小时)
{
	Remove-Variable 分钟_in_06小时
	$private:分钟_in_06小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_07小时)
{
	Remove-Variable 分钟_in_07小时
	$private:分钟_in_07小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_08小时)
{
	Remove-Variable 分钟_in_08小时
	$private:分钟_in_08小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_09小时)
{
	Remove-Variable 分钟_in_09小时
	$private:分钟_in_09小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_10小时)
{
	Remove-Variable 分钟_in_10小时
	$private:分钟_in_10小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_11小时)
{
	Remove-Variable 分钟_in_11小时
	$private:分钟_in_11小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_12小时)
{
	Remove-Variable 分钟_in_12小时
	$private:分钟_in_12小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_13小时)
{
	Remove-Variable 分钟_in_13小时
	$private:分钟_in_13小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_14小时)
{
	Remove-Variable 分钟_in_14小时
	$private:分钟_in_14小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_15小时)
{
	Remove-Variable 分钟_in_15小时
	$private:分钟_in_15小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_16小时)
{
	Remove-Variable 分钟_in_16小时
	$private:分钟_in_16小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_17小时)
{
	Remove-Variable 分钟_in_17小时
	$private:分钟_in_17小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_18小时)
{
	Remove-Variable 分钟_in_18小时
	$private:分钟_in_18小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_19小时)
{
	Remove-Variable 分钟_in_19小时
	$private:分钟_in_19小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_20小时)
{
	Remove-Variable 分钟_in_20小时
	$private:分钟_in_20小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_21小时)
{
	Remove-Variable 分钟_in_21小时
	$private:分钟_in_21小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_22小时)
{
	Remove-Variable 分钟_in_22小时
	$private:分钟_in_22小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

if ('*' -in $分钟_in_23小时)
{
	Remove-Variable 分钟_in_23小时
	$private:分钟_in_23小时 = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
}

#变成字符串
$private:月2 = ($private:月 | Sort-Object -Unique) -join ','
$private:日2 = ($private:日 | Sort-Object -Unique) -join ','
$private:周2 = ($private:周 | Sort-Object -Unique) -join ','
$private:分钟_in_00小时2 = ($private:分钟_in_00小时 | Sort-Object -Unique) -join ','
$private:分钟_in_01小时2 = ($private:分钟_in_01小时 | Sort-Object -Unique) -join ','
$private:分钟_in_02小时2 = ($private:分钟_in_02小时 | Sort-Object -Unique) -join ','
$private:分钟_in_03小时2 = ($private:分钟_in_03小时 | Sort-Object -Unique) -join ','
$private:分钟_in_04小时2 = ($private:分钟_in_04小时 | Sort-Object -Unique) -join ','
$private:分钟_in_05小时2 = ($private:分钟_in_05小时 | Sort-Object -Unique) -join ','
$private:分钟_in_06小时2 = ($private:分钟_in_06小时 | Sort-Object -Unique) -join ','
$private:分钟_in_07小时2 = ($private:分钟_in_07小时 | Sort-Object -Unique) -join ','
$private:分钟_in_08小时2 = ($private:分钟_in_08小时 | Sort-Object -Unique) -join ','
$private:分钟_in_09小时2 = ($private:分钟_in_09小时 | Sort-Object -Unique) -join ','
$private:分钟_in_10小时2 = ($private:分钟_in_10小时 | Sort-Object -Unique) -join ','
$private:分钟_in_11小时2 = ($private:分钟_in_11小时 | Sort-Object -Unique) -join ','
$private:分钟_in_12小时2 = ($private:分钟_in_12小时 | Sort-Object -Unique) -join ','
$private:分钟_in_13小时2 = ($private:分钟_in_13小时 | Sort-Object -Unique) -join ','
$private:分钟_in_14小时2 = ($private:分钟_in_14小时 | Sort-Object -Unique) -join ','
$private:分钟_in_15小时2 = ($private:分钟_in_15小时 | Sort-Object -Unique) -join ','
$private:分钟_in_16小时2 = ($private:分钟_in_16小时 | Sort-Object -Unique) -join ','
$private:分钟_in_17小时2 = ($private:分钟_in_17小时 | Sort-Object -Unique) -join ','
$private:分钟_in_18小时2 = ($private:分钟_in_18小时 | Sort-Object -Unique) -join ','
$private:分钟_in_19小时2 = ($private:分钟_in_19小时 | Sort-Object -Unique) -join ','
$private:分钟_in_20小时2 = ($private:分钟_in_20小时 | Sort-Object -Unique) -join ','
$private:分钟_in_21小时2 = ($private:分钟_in_21小时 | Sort-Object -Unique) -join ','
$private:分钟_in_22小时2 = ($private:分钟_in_22小时 | Sort-Object -Unique) -join ','
$private:分钟_in_23小时2 = ($private:分钟_in_23小时 | Sort-Object -Unique) -join ','



if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
	& 'c:\ProgramData\kasini3000\0k_source.ps1'
}

if ($IsLinux -eq $True)
{
	& '/etc/kasini3000/0k_source.ps1'
}

$private:temp999 = & 'kdir-cmdb.ps1' -被查找的库文件名 'invoke_用户库.ps1'
if ( ($private:temp999 -eq '输入的库路径有错误') -and ($private:temp999 -eq '无返回') )
{
	Write-Error "找不到 'invoke_用户库' "
	exit 1
}
else
{
	$invoke_用户库 = $private:temp999
}

$sqlite_sql =
@"
INSERT INTO "u触发器表" ("月", "日", "分钟_in_0小时", "分钟_in_1小时", "分钟_in_2小时", "分钟_in_3小时", "分钟_in_4小时", "分钟_in_5小时", "分钟_in_6小时", "分钟_in_7小时", "分钟_in_8小时","分钟_in_9小时",
"分钟_in_10小时", "分钟_in_11小时", "分钟_in_12小时", "分钟_in_13小时", "分钟_in_14小时", "分钟_in_15小时", "分钟_in_16小时","分钟_in_17小时", "分钟_in_18小时", "分钟_in_19小时",
"分钟_in_20小时", "分钟_in_21小时", "分钟_in_22小时", "分钟_in_23小时",
"秒", "周", "启用状态", "备注") VALUES ("${private:月2}","${private:日2}","${分钟_in_00小时2}","${分钟_in_01小时2}","${分钟_in_02小时2}","${分钟_in_03小时2}","${分钟_in_04小时2}","${分钟_in_05小时2}","${分钟_in_06小时2}","${分钟_in_07小时2}","${分钟_in_08小时2}","${分钟_in_09小时2}",
"${分钟_in_10小时2}","${分钟_in_11小时2}","${分钟_in_12小时2}","${分钟_in_13小时2}","${分钟_in_14小时2}","${分钟_in_15小时2}","${分钟_in_16小时2}","${分钟_in_17小时2}","${分钟_in_18小时2}","${分钟_in_19小时2}",
"${分钟_in_20小时2}","${分钟_in_21小时2}","${分钟_in_22小时2}","${分钟_in_23小时2}",
${private:秒2},"${private:周2}",${启用状态},"${备注}")
;
"@


try
{
	& $invoke_用户库  -sqlite_sql语句 $sqlite_sql
}
catch
{
	Write-Error '添加u库，触发器失败'
	exit 2
}
finally
{

}
Write-Host -ForegroundColor Green '添加u库，触发器成功'
exit 0

